Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added .setExtraOptions #74

Closed

Conversation

sfinktah
Copy link

To get serious use out of the apexcharts library, it was necessary to expose the complete range of options.

It is now possible to create much more capable graphs, by passing an apexcharts style options argument to setExtraOptions(), e.g.:

        $options = [
            'chart' => [
                'stacked' => true,
            ],
            'fill' => [
                'opacity' => 0.5,
            ],
            'tooltip' => [
                'fixed' => [
                    'enabled' => true,
                    'position' => 'topRight',
                ],
                'followCursor' => true,
            ],
            'plotOptions' => [
                'bar' => [
                    'borderRadius' => 0,
                    'stroke' => [
                        'width' => 5,
                    ],
                ],
                'line' => [
                    'stroke' => [
                        'width' => 8,
                    ]
                ],

            ],
        ];

        return $this->withMeta([
            'chart' => $this->chart->lineChart()
                ->setTitle('Scraping Delay')
                ->addData('minutes', $result->pluck('minutes')->map(fn ($v) => round($v))->all(), 'line')
                ->addData('impressions', $result->pluck('latest_impressions')->all(), 'column')
                ->addData('articles', $result->pluck('latest_articles')->all(), 'column')
                ->addData('failed', $result->map(fn ($row) => $row->failed < $row->minutes ? $row->failed : 0)->map(fn ($v) => round($v))->all(), 'area')
                ->setLabels($result->pluck('name')->all())
                ->setStroke(['curve' => 'stepline'])
                ->setFontColor('currentColor')
                ->setSparkline()
                ->setWidth(512)
                ->setHeight(212)
                ->setExtraOptions($options)
                ->toVue(),
        ]);

@ArielMejiaDev ArielMejiaDev added the enhancement New feature or request label Jul 25, 2023
@ArielMejiaDev
Copy link
Owner

@sfinktah thanks for the PR as it could lead to some breaking changes I need to take some time to figure out how this could make sense at this moment you are able to override options with a new trait introduced by #33

At this moment I would decline this PR, but the idea of override options by a chaining method makes a lot of sense

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants